package com.hust.controller;


import com.hust.domain.User;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.jws.WebParam;
import javax.servlet.http.HttpServletRequest;


/*
 * @author BNer  
 * @date 2020/1/2 11:18
 GotoURLController负责静态页面的跳转控制
 */  
@Controller
public class GotoURLController {
    static final  String ADMINISTRATOR="1";
    static final  String NORMAL_USER="0";
    @GetMapping("/")
    public String  toIndexx (Model model,HttpServletRequest request){

        return "index";
    }
    @GetMapping("/login")
    public String  toLogin(){

        return "login";
    }
    @GetMapping("/index")
    public String  toIndex(Model model, HttpServletRequest request){
        model.addAttribute("username",((User)request.getSession().getAttribute("user")).getuName());
        User user =(User)request.getSession().getAttribute("user");
        if(ADMINISTRATOR.equals(user.getuType())){
            //管理员菜单
            model.addAttribute("menu","menu.json");
        }else {
            model.addAttribute("menu","menu_user.json");

        }
        return "index";
    }
    @GetMapping("/test.html")
    public String  toTest(){

        return "test.html";
    }
    @GetMapping("/pages/welcome.html")
    public String  toWelcom(){

        return "pages/welcome";
    }

    @GetMapping("/pages/member/list.html")
    public String  toMember() {

        return "pages/member/list";
    }

    @GetMapping("/pages/article/list.html")
    public String  toCommodity() {

        return "pages/article/list";
    }
    @RequestMapping("/pages/echarts/echarts{num}.html")
    public String  toEcharts(@PathVariable("num")String num){

        return "pages/echarts/echarts"+num;
    }
    @RequestMapping("/pages/echarts/backBoard")
    public String  toShowHistoryPrice(){

        return "pages/echarts/backBoard";
    }
}
